package top.dingyingying.springboot3.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import top.dingyingying.springboot3.base.PageBean;
import top.dingyingying.springboot3.base.R;
import top.dingyingying.springboot3.entity.TbSoftware;
import top.dingyingying.springboot3.service.TbSoftwareService;
import top.dingyingying.springboot3.vo.PageVo;

@RestController
@RequiredArgsConstructor
@RequestMapping("/tbsoftware")
public class TbSoftwareController {
    private final TbSoftwareService tbSoftwareService;

    @RequestMapping("")
    public R<String> insert(@RequestBody TbSoftware tbSoftware) {
        return tbSoftwareService.insert(tbSoftware);
    }

    @GetMapping("/{ps}/{pn}")
    public R<PageVo<TbSoftware>>query(@PathVariable("ps") Long pageSize, @PathVariable("pn") Long pageNumber, TbSoftware tbSoftware) {
        return tbSoftwareService.query(tbSoftware, PageBean.instance(pageNumber, pageSize));
    }

    @GetMapping("/{id}")
    public R<TbSoftware> queryById(@PathVariable("id") Integer id) {
        return tbSoftwareService.queryById(id);
    }
    @PutMapping("")
    public R<String> update(@RequestBody TbSoftware tbSoftware) {
        return tbSoftwareService.update(tbSoftware);
    }
}
